package com.tian.controller;

import com.tian.annotation.LoginCheckAnnotation;
import com.tian.dto.req.MenuReqDto;
import com.tian.dto.resp.Menu4AuthorRespDto;
import com.tian.dto.resp.MenuRespDto;
import com.tian.dto.resp.PageDto;
import com.tian.service.MenuService;
import com.tian.utils.Result;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * {@code @description:} TODO
 *
 * @author tianwc 公众号：Java后端技术全栈
 * 在线刷题 1200+java面试题和1000+篇技术文章：<a href="https://woaijava.cc/">博客地址</a>
 * {@code @date:} 2024-09-08 18:01
 * {@code @version:} 1.0
 */
@RestController
@RequestMapping("/management/menu")
public class MenuController {

    @Resource
    private MenuService menuService;

    @LoginCheckAnnotation
    @GetMapping("/list")
    public Result<List<MenuRespDto>> allMenu() {
        return menuService.allMenu();
    }
    @LoginCheckAnnotation
    @GetMapping("/list/author")
    public Result<List<Menu4AuthorRespDto>> authorAllMenu() {
        return menuService.allMenu4Author();
    }

    @LoginCheckAnnotation
    @GetMapping("/list/first")
    public Result<List<MenuRespDto>> allFirstMenu( ) {
        return menuService.allFirstMenu();
    }

    @LoginCheckAnnotation
    @GetMapping("/list/first/author/{roleId}")
    public Result<List<Integer>> allFirstMenu( @PathVariable("roleId") Integer roleId) {
        return menuService.userAllMenu4Author(roleId);
    }

    @LoginCheckAnnotation
    @GetMapping("/query")
    public Result<PageDto<List<MenuRespDto>>> query(MenuReqDto menuReqDto) {
        return menuService.query(menuReqDto);
    }

    @LoginCheckAnnotation
    @GetMapping("/query/shouquan")
    public Result<List<MenuRespDto>>  queryShouquan() {
        return menuService.queryShouquan();
    }

    @LoginCheckAnnotation
    @PostMapping("/add")
    public Result<Boolean> add(@RequestBody MenuReqDto menuReqDto) {
        return menuService.add(menuReqDto);
    }
}
